package BigTest;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class test02 {
    public static void main(String[] args)throws IOException {
        //分别创建男生女生集合
        ArrayList<String> BoyList = new ArrayList<>();
        ArrayList<String> GirlList = new ArrayList<>();
        BufferedReader br = new BufferedReader(new FileReader("allname.txt"));
        String str;
        while ((str = br.readLine()) != null){
            String s = str.split("-")[1];
            if(s.equals("男")){
                BoyList.add(str);
            }else {
                GirlList.add(str);
            }
        }
        br.close();
//        System.out.println(BoyList);
//        System.out.println(GirlList);
        ArrayList<Integer> list = new ArrayList<>();
        int boyCount = 0,girlCount = 0;
        Collections.addAll(list,1,1,1,1,1,1,1,0,0,0);
        Random r = new Random();
        for (int i = 0; i < 1000000; i++) {
            int index = r.nextInt(list.size());
            int weight = list.get(index);
            if(weight == 1){
                Collections.shuffle(BoyList);
                String s = BoyList.get(0);
                System.out.println(s);
                boyCount++;
            }else {
                Collections.shuffle(GirlList);
                String s = GirlList.get(0);
                System.out.println(s);
                girlCount++;
            }
        }
        System.out.println("男生" + boyCount);
        System.out.println("女生" + girlCount);
    }
}
